# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Alexander Fehr <pizzapunk gmail com>

pkgname=tracker
pkgver=2.3.6+7+gb27396252
pkgrel=2
pkgdesc="Desktop-neutral user information store, search tool and indexer"
url="https://wiki.gnome.org/Projects/Tracker"
arch=(x86_64)
license=(GPL)
depends=(sqlite icu glib2 libffi util-linux libstemmer libseccomp libsoup
         json-glib upower libnm)
makedepends=(gobject-introspection vala git bash-completion meson)
checkdepends=(python-gobject python-dbus)
provides=(libtracker-{control,miner,sparql}-2.0.so)
groups=(gnome)
_commit=b2739625209c564192b339814264084046e1cf17  # tracker-2.3
source=("git+https://gitlab.gnome.org/GNOME/tracker.git#commit=$_commit"
        0001-libtracker-data-Workaround-SQLite-3.35.x-bug.patch)
sha256sums=('SKIP'
            '00885d437f9257dbba0acad7bae0b9827c1ea09e3ff32727e3217469f3662920')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/_/./g;s/-/+/g'
}

prepare() {
  cd $pkgname

  # https://gitlab.gnome.org/GNOME/tracker/-/merge_requests/382
  git apply -3 ../0001-libtracker-data-Workaround-SQLite-3.35.x-bug.patch

  # test crashes meson: https://github.com/mesonbuild/meson/issues/8591
  sed -i '/tracker-steroids/d' tests/meson.build
}

build() {
  arch-meson $pkgname build
  meson compile -C build
}

check() {
  dbus-run-session meson test -C build --print-errorlogs -t 3
}

package() {
  DESTDIR="$pkgdir" meson install -C build
}
